﻿using System.Text.Json.Nodes;

namespace HelperFromTheSkeleton.HttpManage
{
    public interface IHttpService
    {
        /// <summary>
        /// Post请求
        /// </summary>
        /// <typeparam name="Result">结果类型</typeparam>
        /// <typeparam name="T">请求数据类型</typeparam>
        /// <param name="data">请求数据</param>
        /// <param name="url">请求地址</param>
        /// <returns></returns>
        Task<Result?> PostAsync<Result, T>(T data, string url) where Result : class where T : class;

        /// <summary>
        /// Post请求
        /// </summary>
        /// <returns></returns>
        Task<string> PostAsync(string data, string url);

        /// <summary>
        /// Post请求
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="data"></param>
        /// <param name="url"></param>
        /// <returns></returns>
        Task<JsonObject?> PostAsync<T>(T data, string url) where T : class;

        /// <summary>
        /// 获取字符串结果的Post请求
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="data"></param>
        /// <param name="url"></param>
        /// <returns></returns>
        Task<string?> PostGetStringResultAsync<T>(T data, string url) where T : class;

        /// <summary>
        /// Post请求
        /// </summary>
        /// <typeparam name="Result">结果类型</typeparam>
        /// <typeparam name="T">请求数据类型</typeparam>
        /// <param name="heard">额外的头</param>
        /// <param name="data">请求数据</param>
        /// <param name="url">请求地址</param>
        /// <returns></returns>
        Task<Result?> PostAsync<Result, T>(Dictionary<string, string> heard, T data, string url) where Result : class where T : class;

        /// <summary>
        /// Post请求
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="heard"></param>
        /// <param name="data"></param>
        /// <param name="url"></param>
        /// <returns></returns>
        Task<JsonObject?> PostAsync<T>(Dictionary<string, string> heard, T data, string url) where T : class;

        /// <summary>
        /// 获取字符串结果的Post请求
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="heard"></param>
        /// <param name="data"></param>
        /// <param name="url"></param>
        /// <returns></returns>
        Task<string?> PostGetStringResultAsync<T>(Dictionary<string, string> heard, T data, string url) where T : class;

        /// <summary>
        /// Get请求
        /// </summary>
        /// <typeparam name="Result"></typeparam>
        /// <param name="pairs"></param>
        /// <param name="url"></param>
        /// <returns></returns>
        Task<Result?> GetAsync<Result>(Dictionary<string, object> pairs, string url) where Result : class;

        /// <summary>
        /// Get请求
        /// </summary>
        /// <typeparam name="Result"></typeparam>
        ///  <param name="heard"></param>
        /// <param name="pairs"></param>
        /// <param name="url"></param>
        /// <returns></returns>
        Task<Result?> GetAsync<Result>(Dictionary<string, string> heard, Dictionary<string, object> pairs, string url) where Result : class;

        /// <summary>
        /// From提交
        /// </summary>
        /// <typeparam name="Result"></typeparam>
        /// <typeparam name="T"></typeparam>
        /// <param name="data"></param>
        /// <param name="url"></param>
        /// <returns></returns>
        Task<Result?> FromSubmitAsync<Result, T>(T data, string url) where Result : class where T : class;
    }
}